package manager;

import entity.Teacher;
import iface.IManager;
import java.util.ArrayList;

/**
 *
 * @author Noi
 */
public class TeacherManager implements IManager<Teacher> {

    private ArrayList<Teacher> teacherList;

    public TeacherManager() {
        this.teacherList = new ArrayList<Teacher>();
    }

    @Override
    public boolean add(Teacher teacher) {
        return this.teacherList.add(teacher);
    }

    @Override
    public boolean remove(Teacher teacher) {
        return this.teacherList.remove(teacher);
    }

    @Override
    public Teacher replace(int index, Teacher teacher) {
        return this.teacherList.set(index, teacher);
    }

    @Override
    public int size() {
        return this.teacherList.size();
    }

    @Override
    public Teacher get(int index) {
        return this.teacherList.get(index);
    }

    @Override
    public Teacher getById(int id) {
        for (Teacher obj : this.teacherList) {
            if (obj.getTeacherID() == id) {
                return obj;
            }
        }
        return null;
    }

    @Override
    public Teacher getByName(String name) {
        for (Teacher obj : this.teacherList) {
            if (obj.getTeacherName().equals(name)) {
                return obj;
            }
        }
        return null;
    }

    @Override
    public void setVisible(Teacher obj, boolean value) {
        for (Teacher object : this.teacherList) {
            if (object.getTeacherID() == obj.getTeacherID()) {
                object.setStatus(value);
                break;
            }
        }
    }
}
